package com.itbaizhan.openhis.controller;

import com.itbaizhan.openhis.dto.OperLogDto;
import com.itbaizhan.openhis.service.OperLogService;
import com.itbaizhan.openhis.vo.AjaxResult;
import com.itbaizhan.openhis.vo.DataGridView;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 操作日志controller
 */
@RestController
@RequestMapping("system/operLog")
@Slf4j
public class OperLogController {
	
	@Autowired
	private OperLogService operLogService;
	
	/**
	 * 查询操作日志
	 * @param operLogDto
	 * @return
	 */
	@GetMapping("listForPage")
	public AjaxResult listForPage(OperLogDto operLogDto) {
		log.info("操作日志查询方法");
		DataGridView dataGridView = operLogService.listForPage(operLogDto);
		return AjaxResult.success("查询成功",  dataGridView.getData(),  dataGridView.getTotal());
	}
	
	/**
	 * 批量删除操作日志
	 * @param InfoIds
	 * @return
	 */
	@DeleteMapping("deleteOperLogByIds/{InfoIds}")
	public AjaxResult deleteOperLogByIds(Long[] InfoIds) {
		log.info("删除操作日志,参数：{}", InfoIds);
		return AjaxResult.toAjax(operLogService.deleteOperLogByIds(InfoIds));
	}
	
	/**
	 * 清空操作日志
	 * @return
	 */
	@DeleteMapping("clearOperLog")
	public AjaxResult clearOperLog() {
		log.info("清空操作日志");
		return AjaxResult.toAjax(operLogService.clearOperLog());
	}
}
